<template>
  <div class="log">
    <el-container>
      <!-- 日志显示区域 -->
      <el-header>
        <template>
          <el-table :data="LogData" style="width: 100%">
            <!-- 序号 -->
            <el-table-column type="index" label="序号" align="center">
            </el-table-column>
            <!-- 访问人真实姓名 -->
            <el-table-column
              prop="realname"
              label="访问人真实姓名"
              align="center"
            >
            </el-table-column>
            <!-- 访问方式 -->
            <el-table-column prop="method" label="访问方式" align="center">
            </el-table-column>
            <!-- 访问路径 -->
            <el-table-column prop="content" label="访问路径 " align="center">
            </el-table-column>
            <!-- 访问时间 -->
            <el-table-column label="访问时间" align="center">
                <template slot-scope="scope">
                 <span>{{scope.row.timestamp | fmtDate_global}}</span>
                </template>
            </el-table-column>
          </el-table>
        </template>
      </el-header>
      <!-- 分页查询 -->
      <el-main class="footer">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[2, 4, 6, 8]"
          :page-size="PageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import { get, post } from "@/utils/request";
export default {
  data() {
    return {
      // 表格数据
      LogData: [],
      //分页当前页面大小
      PageSize: 8,
      //分页查询-当前页面数
      currentPage: 1,
      //显示信息总数
      total: 50,
    };
  },
  computed: {},
  methods: {
    //获取所有日志信息
    async getLogData() {
      let data = {
        page: this.currentPage,
        pageSize: this.PageSize,
      };
      let res = await get("/baseLog/pageQuery", data);
      this.LogData = res.data.list;
      this.total = res.data.total;
    },
    //分页-获取当前页面大小
    handleSizeChange(val) {
      this.PageSize = val;
      this.currentPage = 1;
      this.getLogData();
    },
    //分页-获取当前页面数
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getLogData();
    },
  },
  created() {
    this.getLogData();
  },
  mounted() {},
};
</script>
<style scoped>
.footer {
  position: fixed;
  bottom: 20px;
  right: 25px;
}
</style>